#include <crtdbg.h>
#define _CRTDBG_MAP_ALLOC

#include <stdio.h>
#include "New.h"
#include "DDArr.h"
#include <string.h>

int main(){
	int i,j,h,w;
	int *elem;
	_prop *myarr,*newarr;
	w = 3;
	h = 4;
	myarr = new(&prop,4,h,w);
	for (i = 0 ; i < h ; i++){
		for (j = 0 ; j < w ; j++){
			elem = (int *)access(myarr,j,i);
			*elem = (10*i + j);
			printf("%d ",*(int *)access(myarr,j,i));
		}
		printf("\n");
	}

	printf("\n");

	newarr = new(&prop,4,w+1,h+1);
	copy_ddarr(myarr,newarr,2,0);
	
	for (i = 0 ; i < h+1 ; i++){
		for (j = 0 ; j < w+1 ; j++){
			printf("%d ",*(int *)access(newarr,j,i));
		}
		printf("\n");
	}

	printf("\n");

	reload_ddarr(myarr,w-1,h-1);
	
	for (i = 0 ; i < h-1 ; i++){
		for (j = 0 ; j < w-1 ; j++){
			printf("%d ",*(int *)access(myarr,j,i));
		}
		printf("\n");
	}

	printf("\n");
	
	delete(myarr);
	delete(newarr);

	_CrtDumpMemoryLeaks();
	return 0;
}